package cn.com.headfree.menu;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.com.headfree.base.controller.ExBaseController;
import cn.com.headfree.base.controller.ResultData;
import cn.com.headfree.call.IHumanManageWorkFlowServerCall;
import cn.com.headfree.entity.isc.User;

@Controller
@RequestMapping(value = "/commonMenu", produces = "application/json;charset=UTF-8")
public class CommonMenuController extends ExBaseController {
	private static final Logger LOG = LogManager.getLogger(CommonMenuController.class);
	@Autowired
	private IHumanManageWorkFlowServerCall humanManageWorkFlowServerCall;
	/**
	 * 配置环境
	 *  */
	@Value("${common.resId}")  
	private String resId;
	
	@RequestMapping("/findUserResourceByInterface")
    @ResponseBody
    public ResultData findUserResourceByInterface(HttpServletRequest request,HttpServletResponse response) {
		ResultData result = new ResultData();
		try {
			User user = this.getLoginUserInfo(request);
//			String code = getLoginUserId(request,response);
			LOG.info("==============resId=============="+resId+"=======================userId============="+user.getId()+"=================code============="+user.getPrivateIdentityId());
			result=humanManageWorkFlowServerCall.findUserResourceByInterface(resId, user.getId(), user.getPrivateIdentityId());
//			System.out.println("获取到的结果:"+result.getData());
			LOG.info("成功获取human-manage返回的菜单数据:"+result.getData());
        } catch (Exception e) {
            result.setErrorMsg("获取用户对应菜单按钮异常");
            result.setSuccess(false);
            LOG.error("获取用户对应菜单按钮异常", e);
        }
        return result;
	}
}
